package com.itheima.ydd.common;

import lombok.AllArgsConstructor;
import lombok.Data;

@AllArgsConstructor
@Data
public class PageResult {
    //总数
    private Long count;
    //总页数
    private Long totalPages;
    //每页条数
    private Long pageSize;
    //当前页码
    private Long currentPage;
    //列表数据
    private Object data;

    public static PageResult answer(Long count, Long pageSize, Long currentPage, Object data) {

        Long totalPages = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
        return new PageResult(count, totalPages, pageSize, currentPage, data);
    }

}
